<?php
/**********
*前台默认页面
*lsj 2010-08-10
**********/

class indexCtrl extends lib_ctrl
{
    public $Cname = '欢迎光临';
	
    public function _init(){
    	if($_COOKIE['member_uid']!=0){
			$this->view->assign('member_info',array('member_uid'=>$_COOKIE['member_id'],'member_name'=>$_COOKIE['member_name']));
		}
    }

    /*
    *首页
    */
    public function indexAct()
    {
    	$this->view->display();
    }
    
    


    /*
    *信息提示
    *业务逻辑方面的错误信息会在此报出
    *不负责报语法或系统级错误哦……
    */
    public function msgAct()
    {
    	$error = strip_tags(trim($this->getParam('msg')));
        $hideLink = abs(intval($this->getParam('link')));

		if(!$error) $error = '您的权限不够';

		$this->view->assign('error', $error);
        $this->view->assign('hideLink', $hideLink);
		$this->view->display();
    }


    /*
    *显示验证码
    */
    public function captchaAct()
    {
        $width = abs(intval($_REQUEST['w']));#宽
        $height = abs(intval($_REQUEST['h']));#高
        $line = abs(intval($_REQUEST['l']));#线条密度
        $shadow = abs(intval($_REQUEST['s']));#是否开启阴影
        $num = abs(intval($_REQUEST['num']));#显示的字符数
        $char = abs(intval($_REQUEST['char']));#是否显示字母，默认显示数字
        $sname = strip_tags(trim($_REQUEST['sn']));#SESSION变量的名字

        if(!$width) $width = 90;
        if(!$height) $height = 30;
        if(!$line) $line = 30;
        if(!$num) $num = 4;
        if($char) $char = 'a-z';
        else $char = '0-9';

        session_start();

        $captcha = new lib_class_captcha;
        $captcha->SetCharSet($char);//设置字符的区间
        $captcha->SetNumChars($num);//设置显示字符数
        $captcha->SetWidth($width);//图片宽度
        $captcha->SetHeight($height);//图片宽度
        $captcha->UseColour(true); //彩色线条
        if($shadow) $captcha->DisplayShadow(true); //字符阴影
        $captcha->SetNumLines($line);//设置背景线条密度
        $captcha->SetMinFontSize(12);//最低字符大小
        $captcha->SetMaxFontSize(16);//最高字符大小
        $captcha->SetFileType('jpeg');
        $captcha->Create();
        $code = $captcha->GetCode();
        $_SESSION[$sname] = $code;
    }

    /*
    #检查验证码是否正确
    */
    function checkcaptchaAct()
    {
        session_start();
        $sname = strip_tags(trim($_POST['sname']));
        $captcha = strip_tags(trim($_POST['captcha']));
        if(!$sname) $sname = 'captcha';
        if(!$captcha) exit('0');#空数据
        if($captcha && $_SESSION[$sname] == $captcha) exit('1');#正确
        exit('-1');#错误
    }



}



?>